﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.ValentineUI {
    import flash.events.*;
    import Engine.Managers.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import Display.*;
    import flash.text.*;
    import Modules.achievements.data.*;
    import Display.aswingui.*;
    import Modules.stats.types.*;

    public class AchievementsPanel extends JPanel {

        public static const ACHIEVEMENTS_PER_PAGE:int = 4;

        protected var m_achieves:Array;
        protected var m_headerPanel:JPanel;
        protected var m_bodyPanel:JPanel;
        protected var m_footerPanel:JPanel;
        protected var m_achievementsShelf:JPanel;

        public function AchievementsPanel(){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.TOP));
            this.init();
        }
        protected function init():void{
            this.m_achieves = Global.achievementsManager.getAchievementGroup("vday_2011").achievements;
            while ((this.m_achieves.length % ACHIEVEMENTS_PER_PAGE) != 0) {
                this.m_achieves.push(new Achievement(null, null));
            };
            ASwingHelper.setEasyBorder(this, 0, 20);
            this.m_headerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_bodyPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_footerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.append(ASwingHelper.verticalStrut(8));
            this.append(this.makeHeaderPanel());
            this.append(ASwingHelper.verticalStrut(5));
            this.append(this.makeBodyPanel());
            this.append(ASwingHelper.verticalStrut(5));
            this.append(this.makeFooterPanel());
            this.append(ASwingHelper.verticalStrut(15));
            ASwingHelper.prepare(this);
        }
        protected function makeHeaderPanel():JPanel{
            var _local1:String = ((ZLoc.t("Dialogs", "ValUI_achievements_header") + "\n") + ZLoc.t("Dialogs", "ValUI_achievements_header2"));
            var _local2:AssetPane = ASwingHelper.makeMultilineText(_local1, 700, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, EmbeddedArt.brownTextColor);
            this.m_headerPanel.append(_local2);
            return (this.m_headerPanel);
        }
        protected function makeBodyPanel():JPanel{
            this.m_achievementsShelf = new AchievementsScrollingList(this.m_achieves, AchievementsCellFactory, 0, 4, 1);
            ASwingHelper.prepare(this.m_achievementsShelf);
            this.m_bodyPanel.append(this.m_achievementsShelf);
            return (this.m_bodyPanel);
        }
        protected function makeFooterPanel():JPanel{
            var _local1:CustomButton = new CustomButton(ZLoc.t("Dialogs", "ValUI_askforhelp"), null, "PinkButtonUI");
            _local1.setPreferredSize(new IntDimension(200, 35));
            _local1.setMinimumSize(new IntDimension(200, 35));
            _local1.setMaximumSize(new IntDimension(200, 35));
            _local1.addEventListener(MouseEvent.CLICK, this.onMouseClick, false, 0, true);
            this.m_footerPanel.append(_local1);
            return (this.m_footerPanel);
        }
        protected function onMouseClick(_arg1:Event):void{
            if (!Global.world.viralMgr.vdayBragAboutAchievements()){
                UI.displayMessage(ZLoc.t("Dialogs", "ValUI_throttle"), GenericDialogView.TYPE_OK);
            };
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.PRIZES, "share");
        }

    }
}//package Display.ValentineUI 
